#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int MOD = 1'000'000'007;
const int MX = 100'000;

int pow2[MX]; // 2^i

auto init = [] {
    pow2[0] = 1;
    for (int i = 1; i < MX; i++) {
        pow2[i] = pow2[i - 1] * 2 % MOD;
    }
    return 0;
    }();

class Solution {
public:
    int qmi(int a, int k)
    {
        if (k < 0)   return 0;
        int p = 1e9 + 7;
        int res = 1 % p;
        while (k)
        {
            if (k & 1) res = (long long)res * a % p;
            k >>= 1;
            a = (long long)a * a % p;
        }
        return res;
    }

    int numSubseq(vector<int>& nums, int target) {
        sort(nums.begin(), nums.end());
        long long res = 0;
        int l = 0, r = nums.size() - 1;
        while (l <= r)
        {
            if (nums[l] + nums[r] <= target)
            {
                res += pow2[r - l];
                l++;
            }
            else    r--;
        }
        return res % MOD;
    }
};